import cv2
import numpy as np
import os
import glob

path = "/home/jiayu/Desktop/Mou/img/"
label_path = "/home/jiayu/Desktop/Mou/pred/"

for file in glob.glob(os.path.join(path, "*")):
    print(file)
    img = cv2.imread(file, flags=1)
    img = cv2.resize(img,(384, 384), interpolation=cv2.INTER_CUBIC)
    # print(pred.shape)
    pred = cv2.imread(os.path.join(label_path, os.path.basename(file).replace(".tif", ".png")), flags=0)
    pred = cv2.resize(pred, (384,384), interpolation=cv2.INTER_CUBIC)

    # gray = cv2.cvtColor(pred, cv2.COLOR_BGR2GRAY)
    ret, pred = cv2.threshold(pred, 10, 255, cv2.THRESH_BINARY)
    print(pred.shape)
    w, h,c = img.shape
    # white_image = np.ones((w, h, 3)) * 255

    for i in range(w):
        for j in range(h):
            if pred[i, j] > 0:
                img[i, j,: ] = [0, 255, 0]   # 绿

            # if pred[i, j] > 0:
            #     white_image[i, j, :] = [0, 0, 255]   # 蓝

    # white_image = white_image.astype(np.uint8)

    cv2.imwrite(os.path.join("/home/jiayu/Desktop/Mou/combine", os.path.basename(file)),
            img)